#ifndef LINUXGLWINDOW_H
#define LINUXGLWINDOW_H

#ifdef linux

#include <GL/glx.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <X11/extensions/xf86vmode.h>
#include <X11/keysym.h>

#include <iostream>
#include <string>


/* stuff about our window grouped together */
typedef struct {
    Display *dpy;
    int screen;
    Window win;
    GLXContext ctx;
    XSetWindowAttributes attr;
    bool fs;
    bool doubleBuffered;
    XF86VidModeModeInfo deskMode;
    int x, y;
    unsigned int width, height;
    unsigned int depth;
} GLWindow;

/* attributes for a single buffered visual in RGBA format with at least
 * 4 bits per color and a 16 bit depth buffer */
static int attrListSgl[] = {GLX_RGBA, GLX_RED_SIZE, 4,
    GLX_GREEN_SIZE, 4,
    GLX_BLUE_SIZE, 4,
    GLX_DEPTH_SIZE, 16,
    None};

/* attributes for a double buffered visual in RGBA format with at least
 * 4 bits per color and a 16 bit depth buffer */
static int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER,
    GLX_RED_SIZE, 4,
    GLX_GREEN_SIZE, 4,
    GLX_BLUE_SIZE, 4,
    GLX_DEPTH_SIZE, 16,
    None };

class LinuxGLWindow
{
    public:
        //LinuxGLWindow();
        LinuxGLWindow(std::string title, int width, int height, int bits,
                    bool fullscreenflag);

        bool createWindow(std::string title, int width, int height, int bits,
                    bool fullscreenflag);
        bool destroyWindow();
        virtual ~LinuxGLWindow();

        void resizeGLScene(unsigned int width, unsigned int height);
        bool initGL();

        unsigned int getWidth();
        unsigned int getheight();
        std::string getTitle();
        unsigned int getBits();
        unsigned int getFS();
        Display* getDisplay();
        Window getWindow();
        bool isDoubleBuffered();

    protected:
    private:

        bool isLive;
        GLWindow GLWin;
};
#endif
#endif // LINUXGLWINDOW_H
